//@ sourceURL=/static/modules/missions/missions.js
let tableUrl = '/update/queryTaskDetails';//列表
let enameData = ''
var missionsView = new View({
    name: 'missions',
    init_page() {
        console.log('missions-load');
        let ename = u.getParam('type')
        let jobName = u.getParam('itemId')
        if(jobName){
            $('#group_list').attr('placeholder',jobName)
            $('#group_list').attr('disabled','disabled')
        }
        if(ename){
            $('#ename_list').val(ename)
        }
        missionsView.plugins.missions_list.init();
        //日期插件初始化
        $('#datetimeStart').datetimepicker({
            language:  'zh-CN',
            format:'yyyy-mm-dd',
            weekStart: 1, /*以星期一为一星期开始*/
            todayBtn:  1,
            autoclose: 1,
            minView:2, /*精确到天*/
            pickerPosition: "bottom"
        }).on("changeDate",function(ev){  //值改变事件
            //选择的日期不能大于第二个日期控件的日期
            if(ev.date){
                $("#datetimeEnd").datetimepicker('setStartDate', new Date(ev.date.valueOf()));
            }else{
                $("#datetimeEnd").datetimepicker('setStartDate',null);
            }
        });
        $('#datetimeEnd').datetimepicker({
            language:  'zh-CN',
            format:'yyyy-mm-dd',
            weekStart: 1, /*以星期一为一星期开始*/
            todayBtn:  1,
            autoclose: 1,
            minView:2, /*精确到天*/
            pickerPosition: "bottom"
        }).on("changeDate",function(ev){
            //选择的日期不能小于第一个日期控件的日期
            if(ev.date){
                $("#datetimeStart").datetimepicker('setEndDate', new Date(ev.date.valueOf()));
            }else{
                $("#datetimeStart").datetimepicker('setEndDate',new Date());
            }
        });
        $('#bigdatetimeStart').datetimepicker({
            language:  'zh-CN',
            format:'yyyy-mm-dd',
            weekStart: 1, /*以星期一为一星期开始*/
            todayBtn:  1,
            autoclose: 1,
            minView:2, /*精确到天*/
            pickerPosition: "bottom"
        }).on("changeDate",function(ev){  //值改变事件
            //选择的日期不能大于第二个日期控件的日期
            if(ev.date){
                $("#mindatetimeEnd").datetimepicker('setStartDate', new Date(ev.date.valueOf()));
            }else{
                $("#mindatetimeEnd").datetimepicker('setStartDate',null);
            }
        });
        $('#mindatetimeEnd').datetimepicker({
            language:  'zh-CN',
            format:'yyyy-mm-dd',
            weekStart: 1, /*以星期一为一星期开始*/
            todayBtn:  1,
            autoclose: 1,
            minView:2, /*精确到天*/
            pickerPosition: "bottom"
        }).on("changeDate",function(ev){  //值改变事件
            //选择的日期不能大于第二个日期控件的日期
            if(ev.date){
                $("#bigdatetimeStart").datetimepicker('setStartDate', new Date(ev.date.valueOf()));
            }else{
                $("#bigdatetimeStart").datetimepicker('setStartDate',null);
            }
        });
    }
});
/**
 * 方法
 */
missionsView.fn = {
    delete (e) {
        swal($.po('sweetalert', {
            title: "确定要删除该员工吗？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#DD6B55',
            confirmButtonText: '删除',
            cancelButtonText: "取消",
            closeOnConfirm: false,
        }), function (isConfirm) {
            if (isConfirm) {
                alertify.success('删除成功!')
                swal.close();
            }
        });
    },
    render: {
        operation(data, type) {
            if(data == 0){
                var html = '<div>运行中</div>'
            }else if(data == 1){
                var html = '<div>成功</div>'
            }else if(data == 2){
                var html = '<div>失败</div>'
            }
            return html
        }
    }
}
/**
 * 事件
 */
missionsView._event = () => {

}

/**
 * 绑定插件
 */
missionsView.use(new Table({
    name:'missions_list',
    selector: '#missions_list',
    url: tableUrl,
    search_btn: "#search_btn",
    delay: true,
    callback: function () {
        wdAjax.post({
            url: tableUrl,
            cache: false, //禁用缓存
            data:wdUtil.formToJson('#bank_branch_form'),
            success: result => {
                let data = result.taskCount
               $('.going-color').html(data[0].count0)
               $('.gone-color').html(data[0].count1)
               $('.down-color').html(data[0].count2)
            }
        })
    }
}))
